<template>
  <div class="body-container">
    <el-form>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item>
            <el-select v-model="state.sd.bussid" filterable clearable placeholder="选择单据业务类型">
              <el-option v-for="item in state.bussList" :key="item.id" :label="item.bussName" :value="item.id"/></el-select>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item>
            <el-input v-model="state.sd.key1" placeholder="单据号(泛指合同号、单件号、制单号等)" />
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-button size="default" type="primary" icon="Search"  @click="searchDanJu">查询</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-table :data="state.danJuList" border style="width: 100%" class="myeltable">
      <el-table-column label="单据IID" prop="iid"></el-table-column>
      <el-table-column label="单据号(泛指合同号、单件号、制单号等)" prop="ddh"></el-table-column>
      <el-table-column label="制单人" prop="cMaker"></el-table-column>
      <el-table-column label="制单时间" prop="dDate" width="220px">
        <template v-slot="scope">
          <el-date-picker v-model="scope.row.dDateStr" type="datetime" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  style="width: 210px"></el-date-picker>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="120px">
        <template v-slot="scope">
          <el-button size="small" type="primary" @click="updateMakeDate(scope.row.iid, scope.row.dDateStr)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
defineOptions({
  name: "Dashboard",
  inheritAttrs: false,
});
import request from '@/utils/request';
import { ElMessage } from 'element-plus';
import mittBus from '@/utils/mitt';
import { dayjs } from "element-plus";
import {reactive, ref, onMounted, onUnmounted, defineAsyncComponent, defineProps} from "vue";

const state = reactive({
  sd: {
    bussid : undefined,
    key1 : '',
  },
  bussList: [], //所有业务类型列表
  danJuList: [],  //业务类型对应的查询单据列表
})
const searchBuss = ()=>{
  request({url: '/bpmmakedate/getallcbtest', data: {}}).then(data => {
    state.bussList = data
  })
}
const searchDanJu = ()=>{
  request({url: '/bpmmakedate/getbussdanju', data: state.sd}).then(data => {
    state.danJuList = data
  })
}
const updateMakeDate = (iid, dDate) =>{
  request({
    url: '/bpmmakedate/updatedanjuddate',
    data: {bussid:state.sd.bussid, iid:iid, dDate:dDate}
  }).then( res =>{
    ElMessage.success("操作成功")
  })
}
onMounted(() => {
  searchBuss();
});
</script>

<style lang="scss" scoped>

</style>
